package com.gxa.controller.ly.drugManagement;

import com.gxa.common.R;
import com.gxa.service.SysDrugTotalService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


@Api(value = "药品库存日志接口" ,tags = "药品库存日志接口API")
@Controller
@RequestMapping("/drugManagement/drugManagement")
@RequiresRoles(value = {"超级管理员","院长","主任","秘书"},logical = Logical.OR)
public class DrugTotalController {

    @Autowired
    SysDrugTotalService sysDrugTotalService;

    @ResponseBody
    @RequestMapping(value = "/findDrugTotalList",method = RequestMethod.GET)
    @ApiOperation(value = "查找所有药品库存日志接口",notes = "查找所有药品库存日志",httpMethod = "GET", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每一页页数", paramType = "query", dataType = "String", required = true),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=400,message="参数错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R findDrugTotalList(Integer currentPage,Integer pageSize){
        return sysDrugTotalService.findDrugTotalList(currentPage, pageSize);

    }

    /**
     * 修改日志信息
     * @param remark 修改备注
     * @param id 日志编号
     * @return R
     */
    @ResponseBody
    @RequestMapping(value = "/updateByRemark",method = RequestMethod.POST)
    @ApiOperation(value = "修改日志信息",notes = "修改日志信息",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "remark", value = "修改备注", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "id", value = "日志编号", paramType = "query", dataType = "String", required = true),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=400,message="参数错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateByRemark(String remark,Integer id){
        return sysDrugTotalService.updateByRemark(remark, id);
    }


    /**
     * 根据日志id回显日志信息
     * @param id 日志编号
     * @return R
     */
    @ResponseBody
    @RequestMapping(value = "/selectById",method = RequestMethod.POST)
    @ApiOperation(value = "根据日志id回显日志信息",notes = "根据日志id回显日志信息",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "日志编号", paramType = "query", dataType = "String", required = true),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=400,message="参数错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R selectById(Integer id){
        return sysDrugTotalService.selectById(id);
    }



    /**
     * 模糊查询日志列表
     * @param condition 日志编号
     * @param pageSize 每页大小
     * @param currentPage 当前页
     * @return R
     */
    @ResponseBody
    @RequestMapping(value = "/selectDrugTotalByCondition",method = RequestMethod.POST)
    @ApiOperation(value = "模糊查询日志列表",notes = "模糊查询日志列表",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "condition", value = "条件", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页大小", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "currentPage", value = "当前页", paramType = "query", dataType = "String", required = true)
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=400,message="参数错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R selectDrugTotalByCondition(String condition,Integer pageSize,Integer currentPage){
        return sysDrugTotalService.selectDrugTotalByCondition(condition,pageSize,currentPage);
    }



}
